﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace Proyecta.Categorias
{
    public partial class index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet ds = null;
            Proyecta.Data.BO.CategoriasBO oCat = new Data.BO.CategoriasBO();
            Proyecta.Data.DAO.CategoriasDAO daoCat = new  Data.DAO.CategoriasDAO();

            ds = daoCat.Mostrar(oCat);
            GridView2.DataSource = ds;
            GridView2.DataBind();

            //GridView2.idCategoria   
        }

        public void redireccionar()
        {
            Response.Redirect("Categoria.aspx");
        }

        protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void btnNuevo_Click(object sender, EventArgs e)
        {
            redireccionar();
        }

        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Proyecta.Data.BO.CategoriasBO oCat = new Data.BO.CategoriasBO();
            GridViewRow row = GridView2.Rows[e.RowIndex];

            oCat.idCategoria = int.Parse(((TextBox)(row.Cells[1].Controls[0])).Text);
            //operbo.Nombre = ((TextBox)(row.Cells[2].Controls[0])).Text;
            GridView2.EditIndex = -1;
            GridView2.DataBind();
            Response.Redirect("Categoria.aspx?id=" + oCat.idCategoria + "");
        }

        protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            e.Cancel = true;
            GridView2.EditIndex = -1;
            GridView2.DataBind();
        }

        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridView2.EditIndex = e.NewEditIndex;
            GridView2.DataBind();
        }

      
    }
}